﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nissen_Model;
using Nissen_Resources;

namespace Nissen_Manage.Forms
{
	public partial class TestMapManage : Form
	{
		public TestMapManage()
		{
			InitializeComponent();
		}

		private void btnSave_Click(object sender, EventArgs e)
		{
			try
			{
				IList<TestMap> testMaps = (IList<TestMap>)this.dgvTestMap.DataSource;
				TestMapService testMapService = new TestMapService();
				testMapService.SaveOrUpdateTestMaps(testMaps);
				MessageBox.Show(ResourceCommon.GetResource("SaveSuccess"));
			}
			catch (Exception)
			{
				MessageBox.Show(ResourceCommon.GetResource("SaveFail"));
				//throw;
			}
			
		}

		private void TestMapManage_Load(object sender, EventArgs e)
		{
			TestMapService testMapService = new TestMapService();
			IList<TestMap>testMaps = testMapService.GetAllTestMaps();

			BindingDgvTestMap(testMaps);
		}

		private void BindingDgvTestMap(IList<TestMap> testMaps)
		{

			this.dgvTestMap.AutoGenerateColumns = false;
			this.dgvTestMap.DataSource = testMaps;
		}
	}
}
